package com.oepm.biz.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.oepm.biz.DefenceBiz;
import com.oepm.dao.entity.DefencePo;
import com.oepm.dao.entity.QueryInfo;
import com.oepm.dao.mapper.DefenceMapper;
import com.oepm.vo.DataVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class DefenceBizImpl implements DefenceBiz {
    @Resource DefenceMapper defenceMapper;
    @Override
    public int insert(DefencePo defencePo) {
        return defenceMapper.insert(defencePo);
    }

    @Override
    public int delete(String id) {
        return defenceMapper.delete(id);
    }

    @Override
    public int deleteByAcademy(String academy) {
        return defenceMapper.deleteByAcademy(academy);
    }

    @Override
    public int update(DefencePo defencePo) {
        return defenceMapper.update(defencePo);
    }

    @Override
    public DataVo<DefencePo> selectByAcademy(QueryInfo queryInfo, String academy) {
        PageHelper.startPage(queryInfo.getPagenum(),queryInfo.getPagesize());
        List<DefencePo> list = defenceMapper.selectByAcademy(academy);
        PageInfo<DefencePo> result = new PageInfo<>(list);
        return new DataVo(result.getTotal(),result.getList());
    }

    @Override
    public DataVo<DefencePo> selectPu(QueryInfo queryInfo, String academy) {
        PageHelper.startPage(queryInfo.getPagenum(),queryInfo.getPagesize());
        List<DefencePo> list = defenceMapper.selectPu(academy);
        PageInfo<DefencePo> result = new PageInfo<>(list);
        return new DataVo(result.getTotal(),result.getList());
    }


    @Override
    public DataVo<DefencePo> selectByLevel(QueryInfo queryInfo, String level) {
        PageHelper.startPage(queryInfo.getPagenum(),queryInfo.getPagesize());
        List<DefencePo> list = defenceMapper.selectByLevel(level);
        PageInfo<DefencePo> result = new PageInfo<>(list);
        return new DataVo(result.getTotal(),result.getList());
    }
}
